package com.edz.from0507to0513apk.View;

import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.edz.from0507to0513apk.Base.BaseActivity;
import com.edz.from0507to0513apk.Entity.ItemModel;
import com.edz.from0507to0513apk.NettyAndroid.NettyAndroidClientActivity;
import com.edz.from0507to0513apk.R;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class MainActivity extends BaseActivity {

    @BindView(R.id.recycleView)
    RecyclerView recyclerView;

    protected void initView() {
        final List<ItemModel> itemModelList = new ArrayList<ItemModel>();
        itemModelList.add(new ItemModel(R.drawable.ic_launcher_background, "百度地图Locationsdkdemo"));
        itemModelList.add(new ItemModel(R.drawable.ic_launcher_background, "支付宝支付demo"));
        itemModelList.add(new ItemModel(R.drawable.ic_launcher_background, "自定义圆角Dialog"));
        itemModelList.add(new ItemModel(R.drawable.ic_launcher_background, "Socket连接demo"));
        itemModelList.add(new ItemModel(R.drawable.ic_launcher_background, "扫描二维码demo"));
        itemModelList.add(new ItemModel(R.drawable.ic_launcher_background, "音乐播放器demo"));
        itemModelList.add(new ItemModel(R.drawable.ic_launcher_background, "加油后台订单demo"));
        itemModelList.add(new ItemModel(R.drawable.ic_launcher_background, "CircleImageViewDemo"));
        itemModelList.add(new ItemModel(R.drawable.ic_launcher_background, "办公账号助手app"));
        itemModelList.add(new ItemModel(R.drawable.ic_launcher_background, "移动图纸系统app"));
        itemModelList.add(new ItemModel(R.drawable.ic_launcher_background, "Android使用Netty保持长连接"));
        itemModelList.add(new ItemModel(R.drawable.ic_launcher_background, "Android锁控件"));

        GridLayoutManager gridLayoutManager = new GridLayoutManager(this,2);
        recyclerView.setLayoutManager(gridLayoutManager);
        recyclerView.setAdapter(new CommonAdapter<ItemModel>(MainActivity.this, R.layout.item_main, itemModelList) {
            @Override
            protected void convert(ViewHolder holder, ItemModel itemModel, final int position) {
                holder.setImageResource(R.id.iv_image, itemModelList.get(position).getImageId());
                holder.setText(R.id.tv_preview, itemModelList.get(position).getText_preview());
                holder.setOnClickListener(R.id.ll_item, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        switch (position) {
                            case 0:
                                skipAnotherActivity(MainActivity.this, BaiduMapViewActivity.class);
                                break;
                            case 1:
                                skipAnotherActivity(MainActivity.this,AlipayActivity.class);
                                break;
                            case 2:
                                skipAnotherActivity(MainActivity.this, AtyFingerprint.class);
                                break;
                            case 3:
                                skipAnotherActivity(MainActivity.this,SocketTestActivity.class);
                                break;
                            case 4:
                                skipAnotherActivity(MainActivity.this,ScanCodeActivity.class);
                                break;
                            case 5:
                                skipAnotherActivity(MainActivity.this,MusicPlayerActivity.class);
                                break;
                            case 6:
                                skipAnotherActivity(MainActivity.this, GasolineActivity.class);
                                break;
                            case 7:
                                skipAnotherActivity(MainActivity.this,CircleImageViewActivity.class);
                                break;
                            case 8:
                                skipAnotherActivity(MainActivity.this,AccountSaveActivity.class);
                                break;
                            case 9:
                                skipAnotherActivity(MainActivity.this,PstationActivity.class);
                                break;
                            case 10:
                                skipAnotherActivity(MainActivity.this,NettyAndroidClientActivity.class);
                                break;
                            case 11:
                                skipAnotherActivity(MainActivity.this,LockActivity.class);
                                break;
                            default:
                                break;
                        }
                    }
                });
            }
        });
    }

    @Override
    protected void initData() {
//        setFullScreen(true);

    }

    @Override
    protected void setEvent() {

    }

    @Override
    protected int getLayoutResId() {
//        new ScreenManager().setFullScreen(true,this);
//        new ScreenManager().setStatusBar(true,this);
        return R.layout.activity_main;
    }
}
